package com.htw.rv.fast_scroller

import android.content.Intent
import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import com.htw.rv.fast_scroller.databinding.ActivityMainBinding
import com.htw.rv.fast_scroller.follow_scroller_bar.FastScrollerFollowActivity
import com.htw.rv.fast_scroller.grid.FastScrollerBindViewGridActivity
import com.htw.rv.fast_scroller.scroller_bind_view.FastScrollerBindViewActivity
import com.htw.rv.fast_scroller.slide.FastScrollerSlideLetterActivity

class MainActivity : AppCompatActivity(), View.OnClickListener {

    private lateinit var binding: ActivityMainBinding


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityMainBinding.inflate(layoutInflater)
        setContentView(binding.root)

        initViewOnClickListener(
            binding.tvFastScrollerFollow,
            binding.tvFastScrollerBind,
            binding.tvFastScrollerBindGrid,
            binding.tvFastScrollerSlide
        )
    }

    private fun initViewOnClickListener(vararg views: View) {
        views.forEach {
            it.setOnClickListener(this)
        }
    }

    override fun onClick(v: View?) {
        when (v?.id) {
            binding.tvFastScrollerBind.id -> {
                startActivity(Intent(this, FastScrollerBindViewActivity::class.java))
            }
            binding.tvFastScrollerFollow.id -> {
                startActivity(Intent(this, FastScrollerFollowActivity::class.java))
            }
            binding.tvFastScrollerBindGrid.id -> {
                startActivity(Intent(this, FastScrollerBindViewGridActivity::class.java))
            }
            binding.tvFastScrollerSlide.id -> {
                startActivity(Intent(this, FastScrollerSlideLetterActivity::class.java))
            }
        }

    }

}